//
//  MKGlobalFunc.m
//  Teleport
//
//  Created by RLY on 2020/5/14.
//  Copyright © 2020 xxt. All rights reserved.
//

#import "TJGlobalFunc.h"

@implementation TJGlobalFunc


static TJGlobalFunc *instance = nil;

+ (instancetype)globalFunc {
    static dispatch_once_t onceToken;
    dispatch_once(&onceToken, ^{
        instance = [[TJGlobalFunc alloc] init];
        NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
        formatter.timeZone = [NSTimeZone localTimeZone];
        formatter.dateFormat = @"yyyy-MM-dd HH:mm:ss";
        instance.formatter = formatter;
    
    });
    return instance;
}

+ (void)setLanguage:(NSString *)language {
    [[NSUserDefaults standardUserDefaults] setObject:language forKey:appLanguage];
    [[NSUserDefaults standardUserDefaults] synchronize];
    [[NSNotificationCenter defaultCenter] postNotificationName:languageChangedNotification object:nil];
}

+ (NSString *)language {
   return [[NSUserDefaults standardUserDefaults] valueForKey:appLanguage];
}

+ (NSString *)languageDetails {
    if ([self.language isEqualToString:Simplified]) return @"简体中文";
    if ([self.language isEqualToString:English]) return @"English";
    if ([self.language isEqualToString:Korean]) return @"한국어";
    return @"简体中文";
}

+ (NSString *)languageValueToString:(int )languageValue {
    if (languageValue == 0) return Simplified;
    if (languageValue == 1) return English;
    if (languageValue == 2) return Korean;
    return Simplified;
}

+ (NSString *)languageStringToValue:(NSString *)language {
    if ([language isEqualToString:Simplified]) return @"0";
    if ([language isEqualToString:English]) return @"1";
    if ([language isEqualToString:Korean]) return @"2";
    return @"0";
}

+ (NSString *)languageValue:(NSString *)language {
    if ([language isEqualToString:Simplified]) return @"zh_CN";
    if ([language isEqualToString:English]) return @"en_US";
    if ([language isEqualToString:Korean]) return @"ko_KR";
    return @"zh_CN";
}


@end
